#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
	int n, m;
	cin >> n >> m;
	int a[n + 10];
	int t = 0;
	
	for(int i = 1; i <= n; i ++ ) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	int sum = 0;
	for(int i = 1; i <= n; i ++ ) {
		if(sum + a[i] <= m) {
			sum += a[i];
			t ++ ;
		} else {
			break;
		}
	}
	cout << t << endl;
	
	return 0;
}

